package com.kx.yooli.kx.wechat.base.result;

import com.kx.yooli.kx.wechat.po.menu.HttpStatus;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author john_sqwen-childe.wen
 * date 2024/5/23
 * PROJECT_NAME wechat
 * description create ApiResult by john_sqwen
 * and  value is
 */
public class ApiResult<T> {
    private final Logger log = LoggerFactory.getLogger(ApiResult.class);

    //返回数据编码
    private Integer code ;
    //返回状态
    private Boolean status;
    //返回数据信息
    private String message;
    //返回数据内容
    private T data;

    public ApiResult() {
    }

    public ApiResult(Integer code, String message, T data,Boolean status) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    /*
     *全参数方法
     *@param  Integer code, Boolean status,String mesage,T data
     * @return ApiResult
     *
     */
    private static  <T> ApiResult<T> response(Integer code, Boolean status,String message,T data){
        ApiResult<T> apiResult = new ApiResult<T>();
        apiResult.setData(data);
        apiResult.setCode(code);
        apiResult.setMessage(message);
        apiResult.setStatus(status);
        return  apiResult;
    }
    /**
     * 全参 无data
     * @param
     */
    /**
     * 返回成功数据
     * @param void
     * @return this class construct
     */
    public static <T> ApiResult<T> successApi(){
        return  new ApiResult<>(HttpStatus.SUCCESS, org.springframework.http.HttpStatus.OK.name(),null,true);
    }
    /**
     *成功返回数据和信息
     * @param  code message data
     * @return this class construct
     */
    public static  <T> ApiResult<T> successApi(Integer code, String message,T data){
        return new ApiResult<>(code,message,data,true);
    }
    /**
     * 成功 返回数据
     * @param  data
     * @return this class construct
     *
     */
    public  static  <T> ApiResult<T> successApi(T data){
        return new ApiResult<>(HttpStatus.SUCCESS, org.springframework.http.HttpStatus.OK.name(), data,true);
    }
    /**
     * 成功返回信息
     * @param message
     * @return this class construct
     */
    public static  <T> ApiResult<T> resopnse(String message){
        return new ApiResult<>(HttpStatus.SUCCESS,message,null,true);
    }
    /**
     * 失败 不老板娘参数
     * @param void
     * @return this class construct
     */
    public static <T> ApiResult<T> failApi(){
        return new ApiResult<>();
    }
}
